// 根据开始时间、结束时间，获取时间段
export const getStartEndSpliceTime = (startTime, endTime, needSplit = true) => {
  if (startTime && endTime) {
    const startArr = startTime.split(' ')
    const endArr = endTime.split(' ')
    return `${startArr[0]} ${splitTime(startArr[1])} - ${splitTime(endArr[1])}`
  } else {
    return ''
  }
}

const splitTime = (time) => {
  const arr = time.split(':')
  return arr.filter((item, index) => index < arr.length - 1).join(':')
}

// 19:00:00-20:00:00转为19:00-20:00
export const getSpliceTimeText = (timeSlot) => {
  if (timeSlot) {
    const times = timeSlot.split("-")
    if (times.length === 2) {
      const newTimeSlot = times.map(item => {
        const strs = item.split(':')
        return `${strs[0]}:${strs[1]}`
      }).join("-")
      return newTimeSlot
    }
  }
  return ''
};